//
//  GrowlController.m
//  YuTouSeeder
//
//  Created by Huang Dong on 10-9-28.
//  Copyright 2010 limboworks.com. All rights reserved.
//

#import "GrowlController.h"


@implementation GrowlController

- (void)registerGrowl{
	NSBundle *myBundle = [NSBundle bundleForClass:[GrowlController class]];
	NSString *growlPath = [[myBundle privateFrameworksPath]
						   stringByAppendingPathComponent:@"Growl.framework"];
	NSBundle *growlBundle = [NSBundle bundleWithPath:growlPath];
	if (growlBundle && [growlBundle load]) {
		[GrowlApplicationBridge setGrowlDelegate:self];
	} else {
		NSLog(@"Could not load Growl.framework");
	}
}

+ (void)notifyGrowlLoginError:(NSString *)error{
	[GrowlApplicationBridge 
	 notifyWithTitle:@"Login Error"
		description:error
		notificationName:@"YuTouLoginErrorNotification"
		iconData:nil
		priority:2
		isSticky:NO
		clickContext:nil];
}

+ (void)notifyGrowlItunes:(NSString *)sound{
	[GrowlApplicationBridge 
	 notifyWithTitle:@"YuTouSeeder-iTunes Playing"
	 description:sound
	 notificationName:@"YuTouPostNotification"
	 iconData:nil
	 priority:2
	 isSticky:NO
	 clickContext:nil];
}

#pragma mark Growl Methods

- (NSString *)applicationNameForGrowl {
	return @"YuTouSeeder";
}

- (NSDictionary *)registrationDictionaryForGrowl {
	NSArray *allNotifications = [NSArray arrayWithObjects:@"YuTouLoginErrorNotification",@"YuTouPostNotification",nil];
	NSArray *defaultNotifications = [NSArray arrayWithObjects:@"YuTouLoginErrorNotification",@"YuTouPostNotification",nil];
	NSDictionary *registrationDict = [NSDictionary dictionaryWithObjectsAndKeys:allNotifications, GROWL_NOTIFICATIONS_ALL, defaultNotifications, GROWL_NOTIFICATIONS_DEFAULT, nil];
	return registrationDict;
}

@end
